#include "eiennet.hpp"
#include "logger.hpp"
#include "utils/random.hpp"
#include "my_server.hpp"

// using namespace winux;
// using namespace eiennet;
using namespace std;

int main()
{
    winux::SetLocale loc;
    eiennet::SocketLib init;

    Random::init();

    Logger::init();
    // Logger::enabled = 1u;

    MyServer server( "ws_chat", 27066 );
    TRACE("server started" );
    server.run();
    
    return 0;

    // WsHttpServer( winux::String const & serverIp, winux::ushort port, int threadCount = 10, int listenBacklog = 10, double durationSec = 0.1 );
    // eiennet::ws::WsHttpServer server( "", 12075, 10, 10, 0.1 );

    // server.onOpenHandler( [this](eiennet::ws::WsHttpServer::ClientCtxSharedPointer clientCtxPtr, AnsiString const & data, int type ) {
        
    // });
    // server.onCloseHandler( [this](eiennet::ws::WsHttpServer::ClientCtxSharedPointer clientCtxPtr, AnsiString const & data, int type ) {
        
    // });
    // server.onMessageHandler( [] ( eiennet::ws::WsHttpServer::ClientCtxSharedPointer clientCtxPtr, AnsiString const & data, int type ) {
    //     string url = clientCtxPtr->url.getPath();
    //     if( url == "ws_test" ) {
    //         cout << LocalFromUtf8(data) << endl;
    //         clientCtxPtr->websocket.send( LocalToUtf8("从服务器发来的数据:Hello") );
    //     }
    // } );

    // return server.run();

}